import Vue from 'vue'
import Vuex from 'vuex'
import { INC, DEC } from "../mutations/index"

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    count: 0,
  },

  mutations: {
    [INC](state, nub) {
      state.count += nub
    },
    [DEC](state, nub) {
      state.count -= nub
    },
    add(state, num) {
      state.count += num
    },
    littles(state, num) {
      console.log(num);
      state.count -= num;
    }
  },

  actions: {
    asyncInc({ commit }, nub) {
      commit(INC, nub)
    },
    asyncDec({ context }, nub) {
      context.commit(DEC, nub)
    },
    asyncAdd(context, num) {
      context.commit('add', num.num)
    },
    asyncLittle({ commit, dispatch }, num) {
      // console.log(num);
      // console.log(commit)
      // console.log(dispatch)
      commit('littles', num);
      // dispatch('text');   
    },
  },

  getters:{},

  modules: {
  }
})
